Public Class CLookup
    Inherits BOBase

    Protected m_State As LookupDS
    Protected m_DA As Lookups

#Region "   Inherits Implementation"
    Sub New()
        m_State = New LookupDS
    End Sub

    Public Overrides ReadOnly Property DA() As DABase
        Get
            If m_DA Is Nothing Then
                m_DA = New Lookups
            End If

            Return m_DA
        End Get
    End Property

    Public Overrides Property ObjectState() As DataSet
        Get
            Return m_State
        End Get
        Set(ByVal Value As DataSet)
            Try
                m_State = CType(Value, LookupDS)
            Catch ex As InvalidCastException
                Throw New ApplicationException("Invalid look_up Dataset!", ex)
            End Try
        End Set
    End Property

    Public Overrides Sub Init()
        m_State.LOOK_UP.Rows.Clear()
        Dim dr As LookupDS.LOOK_UPRow = m_State.LOOK_UP.NewLOOK_UPRow
        With dr
            .LK_ID_PK = Nothing
            .CATEGORY_NAME = String.Empty
            .TITLE1 = String.Empty
            .SetDATA_TYPE1Null()
            .MIN_LENGTH1 = 0
            .MAX_LENGTH1 = 50            
            .SetIS_REQUIRED1Null()
            .SetIS_UNIQUE1Null()
            .SetTITLE2Null()
            .SetDATA_TYPE2Null()
            .MIN_LENGTH2 = 0
            .MAX_LENGTH2 = 255
            .SetIS_REQUIRED2Null()
            .SetIS_UNIQUE2Null()
            .SetTITLE3Null()
            .SetDATA_TYPE3Null()
            .MIN_LENGTH3 = 0
            .MAX_LENGTH3 = 255
            .SetIS_REQUIRED3Null()
            .SetIS_UNIQUE3Null()
        End With
        m_State.LOOK_UP.Rows.Add(dr)
    End Sub
#End Region

#Region "   Data Properties"
    Protected ReadOnly Property DataRow() As LookupDS.LOOK_UPRow
        Get
            Return CType(Me.Row, LookupDS.LOOK_UPRow)
        End Get
    End Property

    Public Property ID() As System.Int32
        Get
            Return Me.DataRow.LK_ID_PK
        End Get
        Set(ByVal Value As System.Int32)
            Me.DataRow.LK_ID_PK = Value
        End Set
    End Property

    Public Property CategoryName() As System.String
        Get
            Return Me.DataRow.CATEGORY_NAME
        End Get
        Set(ByVal Value As System.String)
            Me.DataRow.CATEGORY_NAME = Value
        End Set
    End Property

    Public Property Title1() As System.String
        Get
            Return Me.DataRow.TITLE1
        End Get
        Set(ByVal Value As System.String)
            Me.DataRow.TITLE1 = Value
        End Set
    End Property

    Public Property DataType1() As System.Byte
        Get
            If Me.DataRow.IsDATA_TYPE1Null Then
                Return Nothing
            Else
                Return Me.DataRow.DATA_TYPE1
            End If
        End Get
        Set(ByVal Value As System.Byte)
            If Value = Nothing Then
                Me.DataRow.SetDATA_TYPE1Null()
            Else
                Me.DataRow.DATA_TYPE1 = Value
            End If
        End Set
    End Property

    Public Property MinLength1() As System.Int32
        Get
            If Me.DataRow.IsMIN_LENGTH1Null Then
                Return Nothing
            Else
                Return Me.DataRow.MIN_LENGTH1
            End If
        End Get
        Set(ByVal Value As System.Int32)
            If Value = Nothing Then
                Me.DataRow.SetMIN_LENGTH1Null()
            Else
                Me.DataRow.MIN_LENGTH1 = Value
            End If
        End Set
    End Property

    Public Property MaxLength1() As System.Int32
        Get
            If Me.DataRow.IsMAX_LENGTH1Null Then
                Return Nothing
            Else
                Return Me.DataRow.MAX_LENGTH1
            End If
        End Get
        Set(ByVal Value As System.Int32)
            If Value = Nothing Then
                Me.DataRow.SetMAX_LENGTH1Null()
            Else
                Me.DataRow.MAX_LENGTH1 = Value
            End If
        End Set
    End Property

    Public Property IsRequired1() As System.Boolean
        Get
            If Me.DataRow.IsIS_REQUIRED1Null Then
                Return Nothing
            Else
                Return Me.DataRow.IS_REQUIRED1
            End If
        End Get
        Set(ByVal Value As System.Boolean)
            If Value = Nothing Then
                Me.DataRow.SetIS_REQUIRED1Null()
            Else
                Me.DataRow.IS_REQUIRED1 = Value
            End If
        End Set
    End Property

    Public Property IsUnique1() As System.Boolean
        Get
            If Me.DataRow.IsIS_UNIQUE1Null Then
                Return Nothing
            Else
                Return Me.DataRow.IS_UNIQUE1
            End If
        End Get
        Set(ByVal Value As System.Boolean)
            If Value = Nothing Then
                Me.DataRow.SetIS_UNIQUE1Null()
            Else
                Me.DataRow.IS_UNIQUE1 = Value
            End If
        End Set
    End Property

    Public Property Title2() As System.String
        Get
            If Me.DataRow.IsTITLE2Null Then
                Return Nothing
            Else
                Return Me.DataRow.TITLE2
            End If
        End Get
        Set(ByVal Value As System.String)
            If Value = Nothing Then
                Me.DataRow.SetTITLE2Null()
            Else
                Me.DataRow.TITLE2 = Value
            End If
        End Set
    End Property

    Public Property DataType2() As System.Byte
        Get
            If Me.DataRow.IsDATA_TYPE2Null Then
                Return Nothing
            Else
                Return Me.DataRow.DATA_TYPE2
            End If
        End Get
        Set(ByVal Value As System.Byte)
            If Value = Nothing Then
                Me.DataRow.SetDATA_TYPE2Null()
            Else
                Me.DataRow.DATA_TYPE2 = Value
            End If
        End Set
    End Property

    Public Property MinLength2() As System.Int32
        Get
            If Me.DataRow.IsMIN_LENGTH2Null Then
                Return Nothing
            Else
                Return Me.DataRow.MIN_LENGTH2
            End If
        End Get
        Set(ByVal Value As System.Int32)
            If Value = Nothing Then
                Me.DataRow.SetMIN_LENGTH2Null()
            Else
                Me.DataRow.MIN_LENGTH2 = Value
            End If
        End Set
    End Property

    Public Property MaxLength2() As System.Int32
        Get
            If Me.DataRow.IsMAX_LENGTH2Null Then
                Return Nothing
            Else
                Return Me.DataRow.MAX_LENGTH2
            End If
        End Get
        Set(ByVal Value As System.Int32)
            If Value = Nothing Then
                Me.DataRow.SetMAX_LENGTH2Null()
            Else
                Me.DataRow.MAX_LENGTH2 = Value
            End If
        End Set
    End Property

    Public Property IsRequired2() As System.Boolean
        Get
            If Me.DataRow.IsIS_REQUIRED2Null Then
                Return Nothing
            Else
                Return Me.DataRow.IS_REQUIRED2
            End If
        End Get
        Set(ByVal Value As System.Boolean)
            If Value = Nothing Then
                Me.DataRow.SetIS_REQUIRED2Null()
            Else
                Me.DataRow.IS_REQUIRED2 = Value
            End If
        End Set
    End Property

    Public Property IsUnique2() As System.Boolean
        Get
            If Me.DataRow.IsIS_UNIQUE2Null Then
                Return Nothing
            Else
                Return Me.DataRow.IS_UNIQUE2
            End If
        End Get
        Set(ByVal Value As System.Boolean)
            If Value = Nothing Then
                Me.DataRow.SetIS_UNIQUE2Null()
            Else
                Me.DataRow.IS_UNIQUE2 = Value
            End If
        End Set
    End Property

    Public Property Title3() As System.String
        Get
            If Me.DataRow.IsTITLE3Null Then
                Return Nothing
            Else
                Return Me.DataRow.TITLE3
            End If
        End Get
        Set(ByVal Value As System.String)
            If Value = Nothing Then
                Me.DataRow.SetTITLE3Null()
            Else
                Me.DataRow.TITLE3 = Value
            End If
        End Set
    End Property

    Public Property DataType3() As System.Byte
        Get
            If Me.DataRow.IsDATA_TYPE3Null Then
                Return Nothing
            Else
                Return Me.DataRow.DATA_TYPE3
            End If
        End Get
        Set(ByVal Value As System.Byte)
            If Value = Nothing Then
                Me.DataRow.SetDATA_TYPE3Null()
            Else
                Me.DataRow.DATA_TYPE3 = Value
            End If
        End Set
    End Property

    Public Property MinLength3() As System.Int32
        Get
            If Me.DataRow.IsMIN_LENGTH3Null Then
                Return Nothing
            Else
                Return Me.DataRow.MIN_LENGTH3
            End If
        End Get
        Set(ByVal Value As System.Int32)
            If Value = Nothing Then
                Me.DataRow.SetMIN_LENGTH3Null()
            Else
                Me.DataRow.MIN_LENGTH3 = Value
            End If
        End Set
    End Property

    Public Property MaxLength3() As System.Int32
        Get
            If Me.DataRow.IsMAX_LENGTH3Null Then
                Return Nothing
            Else
                Return Me.DataRow.MAX_LENGTH3
            End If
        End Get
        Set(ByVal Value As System.Int32)
            If Value = Nothing Then
                Me.DataRow.SetMAX_LENGTH3Null()
            Else
                Me.DataRow.MAX_LENGTH3 = Value
            End If
        End Set
    End Property

    Public Property IsRequired3() As System.Boolean
        Get
            If Me.DataRow.IsIS_REQUIRED3Null Then
                Return Nothing
            Else
                Return Me.DataRow.IS_REQUIRED3
            End If
        End Get
        Set(ByVal Value As System.Boolean)
            If Value = Nothing Then
                Me.DataRow.SetIS_REQUIRED3Null()
            Else
                Me.DataRow.IS_REQUIRED3 = Value
            End If
        End Set
    End Property

    Public Property IsUnique3() As System.Boolean
        Get
            If Me.DataRow.IsIS_UNIQUE3Null Then
                Return Nothing
            Else
                Return Me.DataRow.IS_UNIQUE3
            End If
        End Get
        Set(ByVal Value As System.Boolean)
            If Value = Nothing Then
                Me.DataRow.SetIS_UNIQUE3Null()
            Else
                Me.DataRow.IS_UNIQUE3 = Value
            End If
        End Set
    End Property
#End Region

    Public Shared Function GetLookupList() As DataTable
        Dim ds As New DataSet
        ds = DataHelper.ExecuteDataSet2("GetLookupList")
        Return ds.Tables(0)
    End Function

    Public Shared Function GetLookupDataList(ByVal id As Integer) As DataTable
        Dim ds As New DataSet
        ds = DataHelper.ExecuteDataSet2("GetLookupDataList", id)
        Return ds.Tables(0)
    End Function
End Class
